package org.example.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import org.example.entity.TFile;
import org.example.entity.User;
import org.example.entity.UserDTO;

import java.time.LocalDateTime;
import java.util.List;

public interface UserMapper {



//    List<Admin> selectAll(Admin admin);

//    User selectById(Integer id);

    @Insert("insert into User( username, password, email, login_time, create_time) VALUES (#{username},#{password},#{email},#{loginTime},#{createTime})")
    void insert(User user);
//
//
//    void delete(Integer id);
//
//    void update(Admin admin);
//
    @Select("select * from user where username=#{username}")
    User selectByUsername(String username);

    @Select("select * from user where user.user_id=#{id}")
    User selectByUserId(Integer id);

    List<TFile> selectFileList(int userId);


    @Select("select user_id,username,email,avatar_file,login_time,create_time from user where user_id=#{id}")
    UserDTO selectUserMsg(Integer id);

    void updateById(User update);

    void updateLastLoginTime(Integer userId);

    int updateUserAvatar(@Param("userId") int userid, @Param("avatar") String avatar);//@Param("userId") 是 MyBatis 框架中用于 给方法参数起别名 的注解，主要作用是 让 XML 映射文件或注解 SQL 中能准确识别方法参数，解决 “参数名不匹配” 的问题。

}
